import React from 'react';
import {
  HomeOutlined,
  AppstoreAddOutlined,
  AppstoreOutlined,
  TeamOutlined,
  UserOutlined,
  BarChartOutlined,
  DotChartOutlined,
  PieChartOutlined,
  LineChartOutlined,
  BarsOutlined,
} from '@ant-design/icons';

export const menuList = [
  {
    title: '首页',
    key: '1',
    icon: <HomeOutlined />,
    path: '/home',
  },
  {
    title: '商品',
    key: '2',
    icon: <AppstoreAddOutlined />,
    children: [
      {
        title: '品类管理',
        key: '2-1',
        icon: <BarsOutlined />,
        path: '/category-manage',
      },
      {
        title: '商品管理',
        key: '2-2',
        icon: <AppstoreOutlined />,
        path: '/commodity-manage',
      },
    ],
  },
  {
    title: '用户管理',
    key: '3',
    icon: <TeamOutlined />,
    path: '/user-manage',
  },
  {
    title: '角色管理',
    key: '4',
    icon: <UserOutlined />,
    path: '/character-manage',
  },
  {
    title: '图形图表',
    key: '5',
    icon: <DotChartOutlined />,
    children: [
      {
        title: '柱形图',
        key: '5-1',
        icon: <BarChartOutlined />,
        path: '/bar-chart',
      },
      {
        title: '折线图',
        key: '5-2',
        icon: <LineChartOutlined />,
        path: '/line-chart',
      },
      {
        title: '饼图',
        key: '5-3',
        icon: <PieChartOutlined />,
        path: '/pie-chart',
      },
    ],
  },
];

const routeSelect = [
  {
    name: '/',
    key: '0',
  },
  {
    name: '/home',
    key: '1',
  },
  {
    name: '/category-manage',
    key: '2-1',
  },
  {
    name: '/commodity-manage',
    key: '2-2',
  },
  {
    name: '/commodity-manage/add',
    key: '2-2',
  },
  {
    name: '/commodity-manage/detail',
    key: '2-2',
  },
  {
    name: '/user-manage',
    key: '3',
  },
  {
    name: '/character-manage',
    key: '4',
  },
  {
    name: '/bar-chart',
    key: '5-1',
  },
  {
    name: '/line-chart',
    key: '5-2',
  },
  {
    name: '/pie-chart',
    key: '5-3',
  },
];

export function findKey(route) {
  return routeSelect.find((value) => {
    return value.name === route;
  }).key;
}
